package com.woniuxy.oldobject.entity;


import java.util.HashMap;

/**
 * 相应对象
 */


public class ResponseEntity extends HashMap {
    private final String CODE = "code";//当做map中的key
    private final String MSG = "msg";
    private final String OBJ = "data";

    public ResponseEntity() {

    }

    public ResponseEntity(Object obj) {
        super.put(CODE, 200);
        super.put(MSG, "执行成功");
        super.put(OBJ, obj);
    }

    public ResponseEntity(int code, String message) {
        super.put(CODE, code);
        super.put(MSG, message);
    }

    public ResponseEntity(int code, String message, Object data) {
        super.put(CODE, code);
        super.put(MSG, message);
        if (data != null) {
            super.put(OBJ, data);
        }
    }

    public static final ResponseEntity SUCCESS = new ResponseEntity(200, "执行成功！");
    public static final ResponseEntity ERROR = new ResponseEntity(500, "执行失败！");

    public ResponseEntity putKey(String key, Object obj) {
        super.put(key, obj);
        return this;
    }


}
